package com.mindbook.vip.gawxchatinfo.controller.nostrum;

import com.mindbook.vip.gawxchatinfo.entity.nostrum.PrimaryLiverCancerTreatmentProgramme;
import com.mindbook.vip.gawxchatinfo.service.nostrum.PrimaryLiverCancerTreatmentProgrammeService;
import com.mindbook.vip.gawxchatinfo.utils.crud.CrudUtils;
import com.mindbook.vip.gawxchatinfo.utils.result.Result;
import com.mindbook.vip.gawxchatinfo.utils.result.ResultEnum;
import com.mindbook.vip.gawxchatinfo.utils.result.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @NAME: wxb
 * @DATE: 2022/8/9
 * @DESCRIPTION:
 **/
@Api("原发性肝癌治疗方法")
@RestController
@RequestMapping("primaryLiverCancerTreatmentProgramme")
public class PrimaryLiverCancerTreatmentProgrammeController {

    @Autowired
    private PrimaryLiverCancerTreatmentProgrammeService service;

    @PostMapping("/")
    @ApiOperation("新增")
    private Result add(PrimaryLiverCancerTreatmentProgramme p){
        Integer add = service.add(p);

        CrudUtils.validateAddResult(add);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_ADD_SUCCESS.getMsg());
    }

    @PutMapping("/")
    @ApiOperation("新增")
    private Result put(PrimaryLiverCancerTreatmentProgramme p){
        Integer put = service.put(p);

        CrudUtils.validateAddResult(put);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_UPDATE_SUCCESS.getMsg());
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除")
    private Result del(@PathVariable Integer id){
        Integer removeByPrimaryKey = service.removeByPrimaryKey(id);

        CrudUtils.validateDeleteResult(removeByPrimaryKey);

        return ResultUtils.genSuccessResult(ResultEnum.DATA_DELETE_SUCCESS.getMsg());
    }

    @GetMapping("/list")
    @ApiOperation("列表")
    private Result findList(){
        List<PrimaryLiverCancerTreatmentProgramme> all = service.findAll();

        return ResultUtils.genSuccessResult(all);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询详情")
    private Result findById(@PathVariable Integer id){
        PrimaryLiverCancerTreatmentProgramme byPrimaryKey = service.findByPrimaryKey(id);

        return ResultUtils.genSuccessResult(byPrimaryKey);
    }



}
